//
//  PPAlbumPictureInsertionAlbumView.m
//  pickpic
//
//  Created by Jinxiao on 10/2/16.
//  Copyright © 2016 MicroDream. All rights reserved.
//

#import "PPAlbumPictureInsertionAlbumView.h"

@interface PPAlbumPictureInsertionAlbumView ()
@property (readwrite, nonatomic, strong) UIImageView *imageView;
@property (readwrite, nonatomic, strong) UIButton *selectButton;
@end


@implementation PPAlbumPictureInsertionAlbumView

- (instancetype)init {
    self = [super init];

    _imageView = [[UIImageView alloc] init];
    _imageView.backgroundColor = [UIColor colorWithRGBHex:0xf2f2f2];
    _imageView.clipsToBounds = YES;
    _imageView.contentMode = UIViewContentModeScaleAspectFill;
    [self addSubview:_imageView];

    _selectButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _selectButton.adjustsImageWhenHighlighted = NO;
    _selectButton.contentEdgeInsets = UIEdgeInsetsMake(5, 5, 5, 5);
    [_selectButton setImage:[UIImage imageNamed:@"radio-select-36-white"] forState:UIControlStateNormal];
    [_selectButton setImage:[UIImage imageNamed:@"radio-select-36"] forState:UIControlStateHighlighted|UIControlStateSelected];
    [_selectButton setImage:[UIImage imageNamed:@"radio-select-36"] forState:UIControlStateSelected];
    [_selectButton sizeToFit];
    [self addSubview:_selectButton];

    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];

    _imageView.frame = CGRectMake(0, 6, self.width - 6, self.height - 6);

    _selectButton.top = 3;
    _selectButton.right = self.width - 5;
}

- (void)setAlbum:(PPAlbumModel *)album {
    _album = album;

    [_imageView setCoverImageWithAlbum:album];
}

@end
